package net.xdclass.controller;


import net.xdclass.service.ProductService;
import net.xdclass.util.JsonData;
import net.xdclass.vo.ProductVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王展
 * @since 2024-08-31
 */
@RestController
@RequestMapping("/api/product/v1")
public class ProductController {
    @Autowired
    private ProductService productService;

    @RequestMapping("list")
    public JsonData list(){
        List<ProductVO> productVOS = productService.list();
        return JsonData.buildSuccess(productVOS);
    }

    @RequestMapping("detail/{product_id}")
    public JsonData detail(@PathVariable("product_id") Long productId){
        ProductVO productVO = productService.detail(productId);
        return JsonData.buildSuccess(productVO);
    }


}

